package org.tinygroup.weblayerdemo;

import org.tinygroup.logger.LogLevel;
import org.tinygroup.weblayer.AbstractTinyFilter;
import org.tinygroup.weblayer.WebContext;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * Created by wangwy11342 on 2015/12/30.
 */
public class HelloFilter extends AbstractTinyFilter{
    @Override
    protected void customInit() {

    }

    public void preProcess(WebContext webContext) throws ServletException, IOException {
        logger.logMessage(LogLevel.INFO, "=============before processor=============");
        if(webContext.get("username")==null){
            webContext.getResponse().sendRedirect("validateerror.html");
            return;
        }
        logger.logMessage(LogLevel.INFO, "=============login success=============");
    }

    public void postProcess(WebContext webContext) throws ServletException, IOException {
        logger.logMessage(LogLevel.INFO, "=============after processor=============");
    }
}
